package com.guchenbo.example.socket.bio;

import javax.net.SocketFactory;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @Author gucb
 * @Date 15/09/2017.
 */
public class HttpClient {

    public static void main(String[] args) {
        try {
            SocketFactory socketFactory = SocketFactory.getDefault();
            Socket socket = socketFactory.createSocket("127.0.0.1", 8889);

            InputStream inputStream = socket.getInputStream();
            OutputStream outputStream = socket.getOutputStream();

            byte[] b = new byte[1024];
            inputStream.read();
            inputStream.read(b);

            String s = new String(b);
            System.out.println(s);
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
